package com.hl.toolkit.server.tycoin.account.slaveservice;

import com.tycoin.account.slaveentity.TycoinAccountLog;
import com.tycoin.account.slaverepository.TycoinAccountLogRepository;
import com.tycoin.common.bean.PageInfo;
import com.tycoin.common.entity.Page;
import com.tycoin.common.repository.AbstractRepository;
import com.tycoin.common.service.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional(value = "slaveTransactionManager", readOnly = true)
public class TycoinAccountLogService extends AbstractService<TycoinAccountLog, Long> {


	@Autowired
	private TycoinAccountLogRepository tycoinAccountLogRepository;
	
	
	@Override
	public AbstractRepository<TycoinAccountLog, Long> getRepository() {
 		return tycoinAccountLogRepository;
	}
	
	
	
	public List<TycoinAccountLog> queryByPage(Page page, Map<String, String> parMap) {
		PageInfo pageInfo =new PageInfo();
		Long userId=Long.valueOf(parMap.get("userId"));
		pageInfo.setSize(page.getCurrentPage());
		pageInfo.setPage(page.getBeginIndex());

		org.springframework.data.domain.Page<TycoinAccountLog> pageList = tycoinAccountLogRepository.queryByPage(userId, pageInfo.getPageRequest());
		return pageList.getContent();

	}



	public org.springframework.data.domain.Page getAccountLogByPage(Page page, String userIdStr) {
		PageInfo pageInfo =new PageInfo();
		Long userId=Long.valueOf(userIdStr);
 		pageInfo.setSize(page.getCurrentPage());
		pageInfo.setPage(page.getBeginIndex());

		org.springframework.data.domain.Page<TycoinAccountLog> pageList = tycoinAccountLogRepository.queryByPage(userId, pageInfo.getPageRequest());
		return pageList;

	}
	
	

}
